# Maintainer: Diego Sogari <diego.sogari@falker.com.br>

_realname=laszip
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.2.0
pkgrel=1
pkgdesc="Free and lossless LiDAR compression (mingw-w64)"
arch=('any')
url="http://www.laszip.org/"
license=('LGPL')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-cmake")
source=("${_realname}-${pkgver}.tar.gz::https://codeload.github.com/LASzip/LASzip/tar.gz/v${pkgver}"
        "${_realname}-${pkgver}.patch")
sha256sums=('b8e8cc295f764b9d402bc587f3aac67c83ed8b39f1cb686b07c168579c61fbb2'
            '401cfd64246a92af14d2af79983028ab1794f9bc8f6d20f748cf52360e269fa7')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -Np1 -i "${srcdir}/${_realname}-${pkgver}.patch"
}

build() {
  rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    "../${_realname}-${pkgver}"

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
